
#有问题联系3288588344
#频道：https://pd.qq.com/s/672fku8ge




import json
import random
import requests
import time

#只需要Authorization,写在脚本里就行了,手动挂满听书180分钟就可以,一天跑一次,一定先挂满180分钟再跑
#Authorization = "eyJhbGciOiJSUzI1NiIsImNyaXQiOlsiaXNzIiwianRpIiwiaWF0IiwiZXhwIl0sImtpZCI6IjE1MzEyMDM3NjkiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjE3MjE0NzI2MDEsImlhdCI6MTcyMDE3NjYwMSwiaXNzIjoiaHR0cHM6Ly94aWFvc2h1by53dHp3LmNvbS9hcGkvdjEvbG9naW4vaW5kZXgiLCJqdGkiOiIyMTc1N2Y5MzA3YmQ0NDgzNWEwMTcwY2JhZGNlNzExMyIsInVzZXIiOnsidWlkIjo2Mjk3MDI3MDUsIm5pY2tuYW1lIjoi6Zi_6IiqIiwiaW1laSI6IiIsInV1aWQiOiJmZmZmZmZmZi1mOTUyLWYzNTItMDAwMC0wMDAwMDAwMDAwMDAiLCJkZXZpY2VJZCI6IjIwMjQwNzA1MTg0OTM4M2FiMzllMzQ0ZDliNzVkYzdlMjgyZDljMGQwY2IwYjgwMGQxYmEzYmY0Nzg1MTBhIiwicmVnVGltZSI6MTcxODMzNTI1NywidmlwRXhwaXJlQXQiOjAsInNtX2lkIjoiIiwibnV0IjoxNzE4MzM1MjY3LCJpZnUiOjAsImlzX3JiZiI6MCwiYWN0X2lkIjowLCJiaW5kX2F0IjowLCJ0aWQiOiJEVUt0T3hWMW03M3lIcGNnVE1MOU00UlluQTA0TS1HSXJnMjdSRlZMZEU5NFZqRnROek41U0hCaloxUk5URGxOTkZKWmJrRXdORTB0UjBseVp6STNjMmgxIiwidF9tb2RlIjoyfX0.dwgPvNgfwbkZzfOgLbA0_0-B8c2ChacNcChmTiH8NfkQx4jhYuuICHn6pRamKAZ75J0thbwMZrvHlCh4z7sCQKmsIcpBA7WPJeshiHVNA__hUVq2km2ymXu6dMeVNCbaTyvD9K0nWhERd3XHy2Z6Y8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XNzIiwianRpIiwiaWF0IiwiZXhwIl0sImtpZCI6IjE1MzEyMDM3NjkiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjE3MzIzNjgyODQsImlhdCI6MTczMTA3MjI4NCwiaXNzIjoiIiwianRpIjoiYjI3NzFkNjhmYWUzNzBjZGM4NDcyYTA1NjIxZmVmYWEiLCJ1c2VyIjp7InVpZCI6NjkxNzgzNTgwLCJuaWNrbmFtZSI6IuS4g-eMq-S5puWPi18xMTA4NTE1MDEwMTEiLCJpbWVpIjoiIiwidXVpZCI6IiIsImRldmljZUlkIjoiIiwicmVnVGltZSI6MTczMTA3MjI2MiwidmlwRXhwaXJlQXQiOjAsInNtX2lkIjoiIiwibnV0IjowLCJpZnUiOjAsImlzX3JiZiI6MCwiYWN0X2lkIjowLCJiaW5kX2F0IjowLCJ0aWQiOiJEMjdsaHU0VXlEL0FuQytmbVNISUZhYk51STRKR08zQUdFenk5dkg3TWNyekVYMzEiLCJ0X21vZGUiOjJ9fQ.aQWQzbH4l8nu_CN7XLWzqSiqeG9cx8QUG1GT9AHd0W_Whdc8El0PqeRwejaEJkIBuUs0THFWqe-8fTPOX4rUAe4VKLHxZVhaXP9Xo3FvCxZmJ7ldcqp2rZ2q592-QnvhXgnKz-SgTb4vzm2I5Bqwacw_w_42eRE2vTqCqZ846kg'
t = time.time()
# 查余额
def coin(cookie):
    url = "https://api-gw.wtzw.com/welf/h5/v1/task-list"
    headers = {
        "Authorization": cookie
    }
    data = {
        "module_sign": [
            {
                "sign": "9fdefb36c2ec66942d79b1a9a0a8d85d",
                "category": "time_limit"
            },
            {
                "sign": "0d7debfbc25c2184926b23b480bd2450",
                "category": "daily_task"
            }
        ],
        "t": t
    }
    getJson = json.dumps(data).encode("utf-8")
    response = requests.post(url=url, headers=headers, data=getJson)
    # print(response.text)
    jsondata = json.loads(response.text)
    result = jsondata["user"]["coin_data"]
    print("余额是" + result + "金币")


# 五次幸运抽奖
def lucky_draw(cookie):
    print("=======开始幸运抽奖=======\r")
    url = "https://xiaoshuo.wtzw.com/api/v2/lucky-draw/do-extractin"
    headers = {
        "Authorization": cookie
    }
    data = {
        "t": t,
        "apiVersion": 20190309143259 - 1.9
    }
    for i in range(0, 5):
        response = requests.get(url=url, headers=headers, params=data)
        print(response.text)
        time.sleep(random.randint(1, 5))


# 五次幸运7抽奖
def lucky_draw_seven(cookie):
    print("=======开始幸运7抽奖=======\r")
    url = "https://api-gw.wtzw.com/lucky-seven/h5/v1/lottery"
    querystring = {"t": t}
    payload = "source=3&apiVersion=20190309143259 - 1.9"
    headers = {
        "Authorization": cookie,
        "content-type": "application/x-www-form-urlencoded"
    }
    for i in range(0, 5):
        response = requests.post(url=url, data=payload, headers=headers, params=querystring)
        jsondata = json.loads(response.text)
        print(jsondata,"===")
        result = jsondata["data"]["title"]
        print(result)
    time.sleep(random.randint(1, 5))


# 领宝箱
def box(cookie):
    print("=======开始领宝箱=======\r")
    url = "https://api-gw.wtzw.com/welf/h5/v1/task/treasure/reward"
    headers = {
        "Authorization": cookie,
        "content-type": "multipart/form-data;"
    }
    querystring_box = {"t": t}
    response_box = requests.post(url=url,headers=headers, params=querystring_box)
    print(response_box.text)
    time.sleep(random.randint(1, 5))


# 领宝箱视频
def box_video(cookie):
    print("=======开始领宝箱视频=======\r")
    url = "https://api-gw.wtzw.com/welf/h5/v1/task/treasure/video/reward"
    headers = {
        "Authorization": cookie,
        "content-type": "application/json"
    }
    querystring = {"t": t}
    payload = {
        "position": "welfare_treasurebox_timely",
        "video_prefix": "task_video_two"
    }

    response = requests.request("POST", url, json=payload, headers=headers, params=querystring)
    print(response.text)
    time.sleep(random.randint(1, 5))


# 100次金币
def coin_150(cookie):
    print("=======开始领取100次150金币=======\r")
    url = "https://api-ks.wtzw.com/api/v1/coin/add"
    payload = "position_id=inchapter_top&type=6&sign=1"
    headers = {
        "Authorization": cookie,
        "Host": "api-ks.wtzw.com",
        "Content-Type": "application/x-www-form-urlencoded"
    }
    for i in range(0, 101):
        response = requests.post(url=url, data=payload, headers=headers)
        jsondata = json.loads(response.text)
        print("增加了" + jsondata["data"]["coin"] + "金币", "剩余" + jsondata["data"]["times"] + "次")
        time.sleep(random.randint(1, 5))


def finish_reward(cookie):
    # 113,161
    task_id = [22, 24, 154, 155, 156, 157, 158, 159, 160, 100, 105, 111, 113, 115, 116, 161, 42, 43, 44, 45, 46, 47]
    url = "https://api-gw.wtzw.com/welf/h5/v1/task/finish-task"
    do_url = "https://api-gw.wtzw.com/welf/h5/v1/task/reward"
    headers = {
        "Authorization": cookie
    }
    for id in task_id:
        data = {
            "t": t,
            "task_id": id

        }
        task_data = {
            "t": t,
            "task_id": id,
            "type_prefix": "task"
        }
        video_data = {
            "t": t,
            "task_id": id,
            "type_prefix": "video"
        }
        if id == 113:
            for i in range(0, 5):
                r4 = requests.post(url=url, headers=headers, data=data)
                print(r4.text)
                time.sleep(random.randint(1, 5))
                r5 = requests.post(url=do_url, headers=headers, data=task_data)
                print(r5.text)
                time.sleep(random.randint(1, 5))
                r6 = requests.post(url=do_url, headers=headers, data=video_data)
                print(r6.text)
                time.sleep(random.randint(1, 5))
        else:
            r1 = requests.post(url=url, headers=headers, data=data)
            print(r1.text)
            time.sleep(random.randint(1, 5))
            r2 = requests.post(url=do_url, headers=headers, data=task_data)
            print(r2.text)
            time.sleep(random.randint(1, 5))
            r3 = requests.post(url=do_url, headers=headers, data=video_data)
            print(r3.text)
            time.sleep(random.randint(1, 5))


if __name__ == '__main__':
    # lucky_draw()
    # coin_150()
    cookies = Authorization.split("&")
    for i, ck in enumerate(cookies):
        #print("开始第"+i+"个账号")
        # print("开始第" + str(i) + "个账号")
        print(f"======开始第{i + 1}个账号======")
        lucky_draw_seven(ck)
        box(ck)
        box_video(ck)
        finish_reward(ck)
        # coin()
        time.sleep(5)